var firstMissingPositive = function(arr) {
    let len = arr.length
    arr[arr.length] = -1
    for (let index = 0; index < len; index++) {
        const item = arr[index];
        if (item > len || item <= 0) {
            continue
        } else if (index === item) {
            arr[index] = true
            continue
        } else {
            let temp = item
            let tempIndex = index
            if (temp > len || temp <= 0) {
                arr[temp] = temp
                arr[index] = -1
            }
            while (temp > 0 && temp <= len && temp !== true) {
                let temptempIndex = temp
                temp = arr[temptempIndex]
                arr[temptempIndex] = true
                arr[tempIndex] = arr[tempIndex] === true ? true : -1
                tempIndex = temptempIndex
            }
        }
    }
    console.log(arr)
    for (let j = 1; j < arr.length; j++) {
        if (arr[j] !== true) {
            return j
        }
    }
    return arr.length
}
console.log(firstMissingPositive([3, 3, 3]))